#include <stdio.h>
#include "x.h"
#include <stdlib.h>
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
#include<unistd.h>
int main(int argc,char *argv[])
{

        int fp;
        int readfile;
        int result;
        int count=0;
        char ch;
        char str[16];
        int i=0,j;
        if((fp= open(argv[1],O_RDONLY))==-1)
        {
                printf("Failure to open %s !\n",argv[0]);
                exit(0);
        }
        while((readfile=read(fp,str,16)))
        {
                        printf("%07o",count);
                        for(i=0;i<readfile;i++)
                        printf("  %02x",str[i]);
                        printf("\n");
                        printf("       ");
                        for(j=0;j<readfile;j++)
                        if(str[j]=='\n')
                        printf("  \\n");
                        else
                        printf("%4c",str[j]);
                        printf("\n");
                        count+=readfile;
        }
        printf("%07o ",count);
        printf("\n");
        result=close(fp);
        return 0;
}
